package io.renren.modules.store.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.common.annotation.NoRepeatSubmit;
import io.renren.modules.store.entity.TStoreStaffCommissionRecordEntity;
import io.renren.modules.store.entity.vo.StaffCommissionRecordVo;
import io.renren.modules.store.service.TStoreStaffCommissionRecordService;
import io.renren.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author steakliu
 * @email 2319492349@qq.com
 * @date 2021-01-28 22:44:15e
 */
@RestController
@RequestMapping("member/tstorestaffcommissionrecord")
public class TStoreStaffCommissionRecordController extends AbstractController {
    @Autowired
    private TStoreStaffCommissionRecordService tStoreStaffCommissionRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("member:tstorestaffcommissionrecord:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tStoreStaffCommissionRecordService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/listCommissionRecord")
    @RequiresPermissions("member:tstorestaffcommissionrecord:list")
    public R listCommissionRecord(@RequestParam Map<String, Object> params){
        params.put("sellerId",getSeller());
        Page<StaffCommissionRecordVo> page = tStoreStaffCommissionRecordService.listCommissionRecord(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("member:tstorestaffcommissionrecord:info")
    public R info(@PathVariable("id") Long id){
		TStoreStaffCommissionRecordEntity tStoreStaffCommissionRecord = tStoreStaffCommissionRecordService.getById(id);

        return R.ok().put("tStoreStaffCommissionRecord", tStoreStaffCommissionRecord);
    }

    /**
     * 保存
     */
    @NoRepeatSubmit
    @RequestMapping("/save")
    @RequiresPermissions("member:tstorestaffcommissionrecord:save")
    public R save(@RequestBody TStoreStaffCommissionRecordEntity tStoreStaffCommissionRecord){
		tStoreStaffCommissionRecordService.save(tStoreStaffCommissionRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("member:tstorestaffcommissionrecord:update")
    public R update(@RequestBody TStoreStaffCommissionRecordEntity tStoreStaffCommissionRecord){
		tStoreStaffCommissionRecordService.updateById(tStoreStaffCommissionRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("member:tstorestaffcommissionrecord:delete")
    public R delete(@RequestBody Long[] ids){
		tStoreStaffCommissionRecordService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
